package com.secsys.interceptor;

import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
import com.secsys.dto.SysUserDTO;
import com.secsys.model.TbSysUser;

public class LoginInterceptor extends MethodFilterInterceptor {
    
	/**
	  * @Description  拦截用户是否登录信息
	  * @author      LiusQ
	  * @Date 2011-4-13
	  * @Version 1.1
	  */
	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		// TODO Auto-generated method stub
		Map session=invocation.getInvocationContext().getSession();
		TbSysUser userDTO=(TbSysUser)session.get("userDto");   //获取用户登录信息
		        
		  if(userDTO==null){
			  
			  String uri=ServletActionContext.getRequest().getHeader("referer");
			  session.put("historyUri", uri);
			  return Action.LOGIN;
		  }else{
			  
			   return invocation.invoke();
		  }
	}
   
	 
	 
}
